// 图库管理接口
import request from '@/utils/request'

export function getImageClassList(page = 1, limit = 10) {
  return request({
    url: `/admin/image_class/${page}?limt=${limit}`,
    method: 'get'
  })
}
// 增加图库分类
export function createImageClass(data: { name: string; order: number }) {
  return request({
    url: '/admin/image_class',
    method: 'post',
    data
  })
}
// 更新图库分类
export function updateImageClass(id: number, data: { name: string; order: number }) {
  return request({
    url: `/admin/image_class/${id}`,
    method: 'post',
    data
  })
}
// 删除图库分类
export function deleteImageClass(id: number) {
  return request({
    url: `/admin/image_class/${id}/delete`,
    method: 'post'
  })
}

// 获取指定分类下的图库列表
export function getImageListByClassId(classId: number, page = 1, limit = 10) {
  return request({
    url: `/admin/image_class/${classId}/image/${page}?limt=${limit}`,
    method: 'get'
  })
}
// 修改图片名称
export function updateImageName(id: number, name: string) {
  return request({
    url: `/admin/image/${id}`,
    method: 'post',
    data: { name }
  })
}
// 删除图片
export function deleteImage(ids: number[]) {
  return request({
    url: '/admin/image/delete_all',
    method: 'post',
    data: { ids }
  })
}

// 上传图片 action服务器地址
export const uploadImageAction = '/api/admin/image/upload'
